<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<c:if test="${empty visitor ||visitor.adminGrade > 0}">
	<c:redirect url="wel!welcome.z" />
</c:if>
<head>
	<title>编辑用户信息</title>
	<script type="text/javascript">
	jq(function() {
		jq("form#edit").validate({
			rules: {
			"user.username": {required: true,maxlength: 16},
			"user.realname": {maxlength: 32},
			"user.email": {email: true,maxlength: 64}
			}
		});
	});
	jq(function() {
		jq("form#password").validate({
			rules: {
			"user.password": {required: true,maxlength: 16},
			"newPassword2": {required: true,maxlength: 16,equalTo: "#newPassword"}
			}
		});
	});
	</script>
</head>

<body>

	<form action="u!all.z" method="post" >
		<button type="submit">
			返回列表
		</button>
	</form>
	
	<form action="u!update.z" method="post" id="edit" class="center">
		<label>
			用户名<span class="notice">(必须，1-16个字符之间，区分大小写)</span>
			<br />
			<input type="text" name="user.username" value="${user.username }" />
			
			<br />
		</label>
		<label>
			用户权限
		</label>
			<br />
			<input type='radio' name="user.adminGrade" value="2"
				<c:if test="${user.adminGrade == 2 }">checked="checked"</c:if> />
			普通用户<span class="notice">（查看及增添未发布物料）</span>
			<br />
			<input type='radio' name="user.adminGrade" value="1"
				<c:if test="${user.adminGrade == 1 }">checked="checked"</c:if> />
			超级用户<span class="notice">（可添加物料及BOM）</span>
			<br />
			<input type='radio' name="user.adminGrade" value="0"
				<c:if test="${user.adminGrade == 0 }">checked="checked"</c:if> />
			管理员
			<br />
		<label>
			真名<span class="notice">(32个字符以内)</span>
			<br />
			<input type="text" name="user.realname" value="${user.realname }" />
			<br />
		</label>
		<label>
			email<span class="notice">(64个字符以内)</span>
			<br />
			<input type="text" name="user.email" value="${user.email }" />
			<br />
		</label>

		<button type="submit" class="valid">
			保存
		</button>
	</form>
	
	<form action="u!changePassword.z" method="post" id="password" class="center">
			<label>
			新密码<span class="notice">(必须，1-16个字符之间，区分大小写)</span>
			<br />
			<input type="password" name="user.password" id="newPassword" />
			
			<br />
			</label>
			<label>
			重复新密码<span class="notice">(必须，1-16个字符之间)</span>
			<br />
			<input type="password" name="newPassword2"/>
			
			<br />
			</label>
			<button type="submit" class="valid">
				重设密码
			</button>
		</form>
	
</body>